﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using DevPhone.Controls.LocalizedResources;
using Microsoft.Phone.Controls;
using DevPhone.Controls;

namespace DevPhoneToolkitSample.Samples
{
    public partial class WindowsBoxDateTimeSample : PhoneApplicationPage
    {
        public WindowsBoxDateTimeSample()
        {
            InitializeComponent();
        }

        private void MsgDateClick(object sender, RoutedEventArgs e)
        {
            WindowsBoxService.DateTimePicker()
                .DatePicker(ControlResources.DatePicker_HeaderBox, MsgDateWhenClosed)
                .Show(null);
        }

        private void MsgDateWhenClosed(WindowsBoxResultEventArgs e)
        {
            WindowsBoxService.Settings().DefaultValues();
            if (e.ButtonResult == WindowsBoxButtonResult.ButtonOk)
            {
                MessageBox.Show("Selected Date :" + ((DateTimeWrapper) e.ResultValue).DateTime.ToShortDateString());
            }
        }

        private void MsgDateColorClick(object sender, RoutedEventArgs e)
        {
            WindowsBoxService.Settings()
                .ContentBackgroundBrush(new SolidColorBrush(Colors.Orange))
                .ContentForegroundBrush(new SolidColorBrush(Colors.Blue));
            WindowsBoxService.DateTimePicker()
                .DatePicker(ControlResources.DatePicker_HeaderBox, MsgDateWhenClosed)
                .Show(null);
        }

        private void MsgTimeClick(object sender, RoutedEventArgs e)
        {
            WindowsBoxService.DateTimePicker()
                .TimePicker(ControlResources.TimePicker_HeaderBox, MsgTimeWhenClosed)
                .Show(null);
        }

        private void MsgTimeWhenClosed(WindowsBoxResultEventArgs e)
        {
            if (e.ButtonResult == WindowsBoxButtonResult.ButtonOk)
            {
                MessageBox.Show("Selected Time :" + ((DateTimeWrapper)e.ResultValue).DateTime.ToShortTimeString());
            }
        }

        private void MsgMonthDayClick(object sender, RoutedEventArgs e)
        {
            WindowsBoxService.DateTimePicker()
                .DatePicker(ControlResources.DatePicker_HeaderBox, MsgMonthDayWhenClosed)
                .Show(null, WindowsBoxDatePickerShowPart.DaysAndMonths);
        }

        private void MsgMonthDayWhenClosed(WindowsBoxResultEventArgs e)
        {
            if (e.ButtonResult == WindowsBoxButtonResult.ButtonOk)
            {
                MessageBox.Show("Selected date : Month = " + ((DateTimeWrapper)e.ResultValue).MonthName + " day = " + ((DateTimeWrapper)e.ResultValue).DayNumber);
            }
        }

        private void MsgMonthYearClick(object sender, RoutedEventArgs e)
        {
            WindowsBoxService.DateTimePicker()
                .DatePicker(ControlResources.DatePicker_HeaderBox, MsgMonthYearWhenClosed)
                .Show(null, WindowsBoxDatePickerShowPart.MonthsAndYears);
        }

        private void MsgMonthYearWhenClosed(WindowsBoxResultEventArgs e)
        {
            if (e.ButtonResult == WindowsBoxButtonResult.ButtonOk)
            {
                MessageBox.Show("Selected date : " + ((DateTimeWrapper)e.ResultValue).MonthName + " / " + ((DateTimeWrapper)e.ResultValue).YearNumber);
            }
        }

    }
}